/*
 * 商家搜索
 * @Author: ljb
 * @Date: 2018-03-27 17:51:07
 * @Last Modified by: ljb
 * @Last Modified time: 2018-10-19 11:17:36
 */
<style lang="less" rel="stylesheet/less" type="text/less" scoped>

</style>

<template>
	<Form
		ref="formInline"
		name="search-form"
		inline
		@keydown.native.enter.prevent="confirmSearch">

		<Form-item
			:label-width="isChinese?60:80"
			:label="$t('common.keyword')"
			class="nowarp-search-form">
			<i-input
				v-model="formValidate.keyword"
				:placeholder="$t('customer.keyword')"
				name="search-keyword"
				type="text"/>
		</Form-item>

		<Form-item
			:label-width="isChinese?70:150"
			:label="$t('customer.is_deleted')"
			class="nowarp-search-form">
			<Select
				v-model="formValidate.is_deleted"
				:placeholder="$t('customer.is_deleted')"
				name="search-is_deleted"
				clearable
				filterable>
				<Option
					v-for="(item, key) in deleted_data"
					:key="key"
					:value="String(item.value)">{{ item.label }}</Option>
			</Select>
		</Form-item>

		<Form-item
			:label-width="isChinese?90:150"
			:label="$t('customer.provider_type')"
			class="nowarp-search-form">
			<Select
				v-model="formValidate.provider_type"
				:placeholder="$t('customer.please_select_type')"
				name="search-provider_type"
				clearable
				filterable>
				<Option
					v-for="(item,key) in provider_type_data"
					:value="item.value"
					:key="key">{{ item.label }}</Option>
			</Select>
		</Form-item>

		<Form-item>
			<Button
				type="primary"
				@click="confirmSearch">
				{{ $t('common.search') }}
			</Button>
		</Form-item>

	</Form>
</template>
<script>

export default {

	name: 'AdminCustomerSearchForm',

	data() {
		return {
			deleted_data: [ // 使用状态
				{
					label: this.$t('customer.enable'), // 启用
					value: '0',
				},
				{
					label: this.$t('customer.disable'), // 禁止
					value: '1',
				},
			],
			provider_type_data: [ // 商户类型
				{
					label: this.$t('customer.virtual_provider'), // 虚拟供应商
					value: '1',
				},
				{
					label: this.$t('customer.general_customer'), // 普通商家
					value: '2',
				},
				// {
				// 	label: this.$t('customer.bought_software_customer'), // 购买软件商家
				// 	value: '3',
				// },
			],
			formValidate: {
				provider_type: '', // 商户类型
				show_virtual: '', // 虚拟仓产品显示
				is_deleted: '', // 开启或禁用
				keyword: '',	// 关键词
			}, // 搜索框的对象参数

		};
	},
	computed: {
		isChinese() {
			return this.$i18n.locale === 'zh-CN';
		},
	},
	methods: {

		/**
         * 确认搜索
         * @return {undefined}
         */
		confirmSearch() {
			const param = {

				provider_type: this.formValidate.provider_type,

				is_deleted: this.formValidate.is_deleted,

				keyword: this.formValidate.keyword,

			};

			this.$emit('search', param);
		},

	},

};

</script>
